import Taro, { Component } from '@tarojs/taro'
import { View, Image, Text } from '@tarojs/components'
import style from './item.module.scss'
import {getUnit, headImg} from "@/utils/utils";
import classNames from 'classnames'
import prompt from '@/assets//images/home-prompt.gif'
import {getBrand, goodsScore} from '@/utils/storage'
import lodash from '@/utils/lodash'
import {FyImg, NeedScore} from "@/components/index";
import {PRODUCT_SALES_TEXT} from "@/config/file";

//  商品
export default class HomePrompt extends Component {
  state: any
  props: any
  static options = {
    addGlobalClass: true
  }

  constructor() {
    super(...arguments)
    this.state = {
    }
  }

  componentWillMount() {
    // const config = getAppletConfig()
  }

  render() {
    const { info } = this.props
    return (
      <View className={style.popularProductItem}>
        <FyImg className={style.itemImage} src={headImg(info.images)} />
        <View className={style.itemContent}>
          <View className={classNames(style.itemName, 't-o-e')}>{info.name}</View>
          <View className={classNames(style.itemPrice, 't-o-e')}>
            {goodsScore(info.needScore) &&<Text className={style.needScore}>{info.needScore}{getBrand()}+</Text>}
            <Text className='f-s-26'>
              {Number(info.salePrice)}元
            </Text>
          </View>
          {!!info.salesNumber && <View className={classNames(style.salesNumber, 'd-f', 'j-c-b')}>
            <div>{PRODUCT_SALES_TEXT} {getUnit(info.salesNumber, '+')}</div>
            <s className={style.originPrice}>￥{Number(info.originPrice)}</s>
          </View>}
        </View>
      </View>)
  }
}
